<?php

class content extends CP_Controller {

    //put your code here
    function __construct() {
        parent::__construct('tc_content', 'content_', 'id');
    }

    function index() {
        $this->viewport('');
    }

    function viewport($type = '') {
        $this->assigns->type = $type;
        echo $c = $this->load->view('cms/cp/tc_content/viewport', $this->assigns, true);
    }

    function bindingbytype($type = null) {
        $where = " WHERE TRUE ";
        if (!empty($type))
            $where = " WHERE `{$this->prefix}type` = '$type' ";
        $this->backend_model->datatables_config = array(
            "table" => "`$this->table`",
            "select" => " SELECT SQL_CALC_FOUND_ROWS * ",
            "from" => " FROM `{$this->table}` ",
            "where" => " $where ",
            "order_by" => " ORDER BY `{$this->prefix}insert` DESC ",
            "columnmaps" => array(
            )
        );
        $this->bindingdata();
    }

    function editpanel($type = '') {
        $this->assigns->type = $type;
        $Id = (int) $this->input->post('Id');
        if ($Id > 0) {
            $this->assigns->item = $this->backend_model->onGet($Id);
            $type = $this->assigns->item->content_type;
        }
        switch ($type) {
            default:
                $c = $this->load->view('cms/cp/tc_content/editpanel', $this->assigns, true);
        }

        $R["result"] = 1;
        $R["message"] = 'SUCCESS !';
        $R["htmlreponse"] = $c;
        $this->output->set_header('Content-type: application/json');
        $this->output->set_output(json_encode($R));
    }

}

?>
